package com.example.tyz1201.haha.Adapter;

import android.content.Context;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
import android.widget.TextView;

import com.example.tyz1201.haha.Model.Data;
import com.example.tyz1201.haha.Model.JokesData;
import com.example.tyz1201.haha.R;

import java.util.ArrayList;
import java.util.List;
import java.util.zip.Inflater;

/**
 * Created by tyz1201 on 2016/4/14.
 */
public class JokesAdapter extends BaseAdapter {

    List<JokesData> datas = new ArrayList<>();
    Context context;

    public JokesAdapter(List<JokesData> datas, Context context) {
        this.datas = datas;
        this.context = context;
    }

    @Override
    public int getCount() {
        return datas.size();
    }

    @Override
    public Object getItem(int position) {
        return datas.get(position);
    }

    @Override
    public long getItemId(int position) {
        return position;
    }

    @Override
    public View getView(int position, View convertView, ViewGroup parent) {
        LayoutInflater inflater = LayoutInflater.from(context);
        View view = inflater.inflate(R.layout.item_jokes, parent, false);

        TextView tv_jokes_content = (TextView) view.findViewById(R.id.tv_jokes_content);
        tv_jokes_content.setText(datas.get(position).getTitle());

        return view;
    }
}
